Fix config-read chunk cap to cover full MAX_CONFIG_SIZE (MJ-14)#8
Open
balloob wants to merge 1 commit into
Open
Fix config-read chunk cap to cover full MAX_CONFIG_SIZE (MJ-14)#8balloob wants to merge 1 commit into
balloob wants to merge 1 commit into
Conversation
The read-config chunk loop used a hardcoded cap of 10 chunks. Because the cap was a magic number decoupled from MAX_CONFIG_SIZE, a config larger than the cap's reach could never be fully read: the client loops until it has `total` bytes and the firmware simply stops sending, so the client retries/times out forever. Derive the cap from MAX_CONFIG_SIZE instead, using the smallest per-chunk payload (MAX_RESPONSE_DATA_SIZE - 6, the chunk-0 size) so it is always sufficient and scales automatically if MAX_CONFIG_SIZE changes. Per-chunk size and framing are unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finding MJ-14 (Silabs side)
The read-config chunk loop in
handle_config_read(opendisplay_pipe.c) capped the number of response chunks at a hardcodedmax_chunks = 10. Because the cap was a magic number decoupled fromMAX_CONFIG_SIZE, any config whose length exceeds the cap's reach can never be fully read: the client loops until it has receivedtotalbytes, but the firmware stops sending after the cap, so the client retries/times out indefinitely.Fix
Derive the cap from
MAX_CONFIG_SIZEso a full config is always readable and the cap scales automatically ifMAX_CONFIG_SIZEchanges:Chunk 0 carries a 4-byte header plus a 2-byte length prefix (94 payload bytes); later chunks carry only the 4-byte header (96 payload bytes). Sizing against the smallest per-chunk payload (
MAX_RESPONSE_DATA_SIZE - 6 = 94) guarantees sufficiency. Per-chunk size and framing are unchanged.Old vs new max readable size
With
MAX_RESPONSE_DATA_SIZE = 100:MAX_CONFIG_SIZE→ covers the full config by construction.Note: on the Silabs side
MAX_CONFIG_SIZEis currently 512, which is already below the old 958 B reach, so the MJ-14 symptom does not manifest here today — this change is hardening that ties the read cap toMAX_CONFIG_SIZEand removes the fragile magic number. WithMAX_CONFIG_SIZE = 512the derived cap is 6 chunks (574 B raw capacity), still covering the full config. MJ-14 also requires the companion read-cap raises on the nRF and Arduino firmwares, whereMAX_CONFIG_SIZEis larger and the bug is live.Verify
No SLC /
arm-none-eabi-gcc/cmake_gcctoolchain available in this environment, so no firmware build. The full file cannot be host-compiled without the Silabs SDK headers (sl_bt_api.h). The isolated cap expression was host-compiled clean undergcc -Wall -Wextra -Wconversionand verified to yieldmax_chunks = 6covering 512 B.🤖 Generated with Claude Code
https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR